-
Notifications
You must be signed in to change notification settings - Fork 161
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(WIP): adding timestamp to exchange rates of denoms #2243
Conversation
for _, v := range exgRatesForDenom { | ||
if len(v) > int(noOfRecords) { | ||
ers := v | ||
// sort the list with descending order by timestamp | ||
// only keep latest noOfRecords | ||
sort.Slice(ers, func(i, j int) bool { return ers[i].Timestamp.After(ers[j].Timestamp) }) | ||
// exgRatesForDenom[k] = ers | ||
for _, d := range ers[noOfRecords:] { | ||
k.DeleteExgRateWithTimestamp(ctx, d.ExchangeRateTuples.Denom, d.Timestamp) | ||
} | ||
} | ||
} |
Check warning
Code scanning / CodeQL
Iteration over map
Codecov Report
@@ Coverage Diff @@
## main #2243 +/- ##
==========================================
- Coverage 75.38% 69.98% -5.41%
==========================================
Files 100 168 +68
Lines 8025 12748 +4723
==========================================
+ Hits 6050 8922 +2872
- Misses 1589 3226 +1637
- Partials 386 600 +214
|
@@ -118,6 +118,17 @@ message AggregateExchangeRateVote { | |||
string voter = 2 [(gogoproto.moretags) = "yaml:\"voter\""]; | |||
} | |||
|
|||
// ExchangeRatesWithTimestamp - store the exchange rate of denom with price timestamp | |||
message ExchangeRatesWithTimestamp { | |||
ExchangeRateTuple exchange_rate_tuples = 1 [ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is this repeated
or single?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
single only
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's make sure to clarify the design here.
We need to allow:
- Scenarios where most denoms have up to date prices, but one or two tokens have old prices
- Leverage module must be able to know the age of the price it received (and this information must vary per denom)
- Leverage module will need
PriceModeRecent
which allows old prices for frontend, but all other price modes likePriceModeSpot
reject old prices. I can build this when the time comes
I am closing this pull request |
Description
We are storing exchange prices with timestamps for denoms in Oracle on every block , so whenever any module requested
GetExchangeRate
from oracle it will return latest exchange rate of denom from store.It will keep no of
HistoricStampPeriod
records for every denom on oracle , so whenever chain halted or no prices from price-feeder , oracle will return latest exchange rate of denom from store.Messages and Genesis ---
Query ---
Author Checklist
All items are required. Please add a note to the item if the item is not applicable and
please add links to any relevant follow up issues.
I have...
!
to the type prefix if API or client breaking changeCHANGELOG.md
Reviewers Checklist
All items are required. Please add a note if the item is not applicable and please add
your handle next to the items reviewed if you only reviewed selected items.
I have...